<?php
class user extends myphp{
	function reglog(){
		if(isset($_GET['k'])){
			$this->display(['reglog'],['登陆']);
		}else{
			$this->display(['reglog'],['注册']);
		}
	}
	function index(){
		session_start();
		$_SESSION['user']=$_POST['user'];
		$user=$_POST['user'];
		$psd=$_POST['psd'];
		$b=$_POST['button'];
		if($b=="注册"){
		$this->table('user')->select('user',"user='$user'");
		foreach($this->res as $v);
		if(isset($v['user'])){
			echo "用户名已存在！";
		}else{	
			$this->table('user')->insert("user,psd","'$user','$psd'");
			$this->display(['user'],[$user]);
			}
		}
		if($b=="登陆"){
			$this->table('user')->select('user,psd',"user='$user' and psd='$psd'");
			foreach($this->res as $v);
			if(isset($_POST['psd'])&&isset($v['user'])){
				$this->display(['user'],[$user]);
			}else{	
				echo "用户名或密码错误！";
			}	
		}	
	}
	function del(){
		$user=null;
		$this->table('user')->select('id,user',"user!='$user'");
		foreach($this->res as $v){
			$id=$v['id'];
			$user.=$v['user']."<input type='checkbox' value=$id>".'<br>';
		}
		$this->assign(['user'],[$user]);
	}
	function dels(){
		$id=$_POST['id'];
		if(strlen($id)==1){
			$this->table('user')->delete("id=$id");
		}else{
			$this->table('user')->delete("id in ($id)");
		}
		$user=null;
		$this->table('user')->select('id,user');
		foreach($this->res as $v){
			$id=$v['id'];
			$user.=$v['user']."<input type='checkbox' value=$id>".'<br>';
		}
		$this->assign(['user'],[$user]);
	}	
}
















	
